package com.lin.csdn.dao.impl;

import com.lin.csdn.dao.BaseDao;
import com.lin.csdn.model.vo.TalkVO;

import java.util.ArrayList;
import java.util.List;

public class TalkDao extends BaseDao {

    public Object search(int userId,int targetId){
        List<Object> list=new ArrayList<>();
        list.add(targetId);
        list.add(userId);
        Class<TalkVO> cls=TalkVO.class;
        return find("SELECT * FROM talk where targetid=? and userid=?",list,cls);
    }
    public Object searchUserTalk(int userId,int targetId){
        List<Object> list=new ArrayList<>();
        list.add(userId);
        list.add(targetId);
        //反转用户id的顺序，提出不同的聊天记录
        Class<TalkVO> cls=TalkVO.class;
        return find("SELECT * FROM talk where targetid=? and userid=?",list,cls);
    }



    public void addTalk(int userId,int targetId,String date,String context){
        List<Object> list=new ArrayList<>();
        list.add(targetId);
        list.add(userId);
        list.add(context);
        list.add(date);
        update("INSERT INTO talk (targetid,userid,context,date) VALUES (?,?,?,?)",list);
    }
}
